package com.example.online_order.mapper;

import com.example.online_order.pojo.Orders;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface OrdersMapper {

//    查询（订单号查询，模糊查询：用户名查询，菜品查询；全表查询） 新增 删除（客户删除只能让客户自己看不见，不实际删除记录 商家可以删除记录），不支持修改

    @Select("select * from orders where id = #{id}")
    public Orders findById(Integer id);

    @Select("select * from orders where orderNum =#{orderNum}")
    public Orders findByOrderNum(String orderNum);

    @Select("select * from orders where userName like '%${userName}%' or goodsName like '%${goodsName}%'")
    public List<Orders> findLikeUserNameAndProduct(String userName, String goodsName);

    @Select("select * from orders")
    public List<Orders> findAll();

    @Insert("insert into orders  (id,userName,phone,orderTime,tableNum,price,address,pickUpNum,remarks,ifPacking,ifCoupons,orderNum,status,flag,goodsId,goodsName,ifeva) values (null,#{userName},#{phone},#{orderTime},#{tableNum},#{price},#{address},#{pickUpNum},#{remarks},#{ifPacking},#{ifCoupons},#{orderNum},#{status},#{flag},#{goodsId},#{goodsName},#{ifeva})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    public Integer addOrder(Orders orders);

    @Delete("delete from orders where id= #{id}")
    public Integer deleteById(Integer id);


    public Integer deleteByids(@Param("ids") int[] ids);


    @Update("update orders set flag= 0 where id= #{id}")
    public  Integer clientDlite(Integer id);


    @Select("select * from orders where userName = #{userName}")
    List<Orders> findByUserName(String userName);

    @Update("update orders set ifeva =1 where id= #{id}")
    Integer clientUpdate(Orders orders);
}
